#ifndef SQUAREDETECT_API_H
#define SQUAREDETECT_API_H

#define LINE_SQUARE_NUM 11
#define STD_SQUARE_NUM 9
#include "UHY_LinearSVM.h"
#include <string>
using namespace std;
//#define NEON_QRBAR_CODE_OPTIMIZATION 1

struct DECTRECT
{
	int left, top, right, bottom;
};

struct RecogResult
{
	DECTRECT realRect[11]; //11个识别块
	DECTRECT stdRect[9];   //标准9宫格
	int baixibao_idx;      //白细胞识别结果
	int yaxiaosuanyan_idx; //亚硝酸盐识别结果
	int niaodanyuan_idx;   //尿胆原识别结果
	int danbaizhi_idx;     //蛋白质识别结果
	int suanjiandu_idx;    //酸碱度识别结果
	int qianxue_idx;       //潜血识别结果
	int bizhong_idx;       //比重识别结果
	int tongti_idx;        //酮体识别结果
	int danhongsu_idx;     //胆红素识别结果
	int putaotang_idx;     //葡萄糖识别结果
	int kanghuaixuesuan;   //抗坏血酸识别结果
};

class CDetectModelCls;
struct DETECT_DATA;

class CUHYRecogCls
{

public:
	CUHYRecogCls();
	~CUHYRecogCls();
public:
	void DetectInit(char *);

	bool SquareDetectRecog(unsigned char* BGRData, int src_wd, int src_ht, RecogResult &pRealRes);

    bool BrightDetect(unsigned char* imageData,int wd, int ht,unsigned char lowValue,unsigned char highValue);

	void DetectRelease();

private:

	bool SquareDetect(unsigned char* imageData, int wd, int ht, DECTRECT* pRealRect,DECTRECT* pStdRect);
	int RecogSingleRect(unsigned char *src_data, int width, int height, DECTRECT *sample_rect, 
		int class_num, float *mean_std_bgr_inv, const struct model *model_);

private:
	CDetectModelCls *Front_FastDetectCls;

	DETECT_DATA *SquarePos;
	// SVM model
	struct model *BaiXiBaoModel;        // 白细胞模型
	struct model *YaXiaoSuanYanModel;   // 亚硝酸盐模型
	struct model *NiaoDanYuanModel;     // 尿胆原模型
	struct model *DanBaiZhiModel;       // 蛋白质模型
	struct model *SuanJianDuModel;      // 酸碱度模型
	struct model *QianXueModel;         // 潜血模型
	struct model *BiZhongModel;         // 比重模型
	struct model *TongTiModel;          // 酮体模型
	struct model *DanHongSuModel;       // 胆红素模型
	struct model *PuTaoTangModel;       // 葡萄糖模型
	struct model *KangHuaiXueSuanModel; // 抗坏血酸模型
};
#endif
